<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title></title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" href="../../layui/css/layui.css" media="all" />
	<link rel="stylesheet" href="../../css/font_eolqem241z66flxr.css" media="all" />
    <style>
        #environments li{
            width: 23%;
            margin: 0.5% 0.5%;
            float: left;
            overflow: hidden;
        }
        img{
            display: inline-block;
            width: 300px;
            height: 300px;
            vertical-align: middle;
        }
    </style>
</head>
<body class="childrenBody">
    <div class="layui-collapse">
        <h1 class="layui-colla-title" id="company_name"></h1>
    </div>
    <hr class="layui-bg-blue">
    <div class="layui-collapse">
        <div class="layui-colla-item">
            <h4 class="layui-colla-title">公司概要</h4>
            <div class="layui-colla-content layui-show">
                <table class="layui-table">
                    <colgroup>
                        <col width="150">
                        <col>
                    </colgroup>
                    <tbody>
                    <tr>
                        <td>公司规模</td>
                        <td id="company_size"></td>
                    </tr>
                    <tr>
                        <td>融资规模</td>
                        <td id="company_finance"></td>
                    </tr>
                    <tr>
                        <td>行业类型</td>
                        <td id="type"></td>
                    </tr>
                    <tr>
                        <td>拉勾URL</td>
                        <td><a href="" target="_blank" id="company_url"></a></td>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
        <div class="layui-colla-item">
            <h4 class="layui-colla-title">公司介绍</h4>
            <div class="layui-colla-content layui-show" id="description"></div>
        </div>
        <div class="layui-colla-item">
            <h4 class="layui-colla-title">爬虫信息</h4>
            <div class="layui-colla-content layui-show">
                <table class="layui-table">
                    <colgroup>
                        <col width="150">
                        <col>
                    </colgroup>
                    <tbody>
                    <tr>
                        <td>记录创建时间</td>
                        <td id="create_at"></td>
                    </tr>
                    <tr>
                        <td>记录更新时间</td>
                        <td id="update_at"></td>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
        <div class="layui-colla-item">
            <h4 class="layui-colla-title">公司环境</h4>
            <div class="layui-colla-content layui-show" id="environments"></div>
        </div>
        <div class="layui-clear"></div>
    </div>
	<script type="text/javascript" src="/new_layui/layui.js"></script>
	<script>
        function GetQueryString(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
            var r = window.location.search.substr(1).match(reg);  //获取url中"?"符后的字符串并正则匹配
            var context = "";
            if (r != null)
                context = r[2];
            reg = null;
            r = null;
            return context == null || context == "" || context == "undefined" ? "" : context;
        }

        layui.use(['element','jquery','flow'], function(){
            var $ = layui.jquery, element=layui.element;
            var flow = layui.flow;
            //当你执行这样一个方法时，即对页面中的全部带有lay-src的img元素开启了懒加载（当然你也可以指定相关img）
            flow.lazyimg();
            //参数检测
            var id = GetQueryString('id');
            if(id == ''){
                alert('非法参数！');
                var iframe_close_tag = $('.layui-this .layui-tab-close',window.parent.document);
                if(iframe_close_tag.length != 0){
                    iframe_close_tag.click();
                }else{
                    window.opener=null;
                    window.close();
                }
            }
            $.get('/php/public/api/lagou/company.html?id='+id,function (xhr) {
                if(!xhr){
                    alert('暂无该公司信息！');
                    var iframe_close_tag = $('.layui-this .layui-tab-close',window.parent.document);
                    if(iframe_close_tag.length != 0){
                        iframe_close_tag.click();
                    }else{
                        window.opener=null;
                        window.close();
                    }
                }
                //console.log(xhr);
                document.title = xhr.total_name + '—详情';
                $('#company_name').text(xhr.total_name);
                //console.log(typeof xhr.description);
                $('#description').html(xhr.description.split('*_*').join('<br/>'));
                $('#company_size').text(xhr.size);
                $('#company_finance').text(xhr.finance);
                $('#type').text(xhr.type);
                $('#create_at').text(xhr.create_at);
                $('#update_at').text(xhr.update_at);
                $('#company_url').text(xhr.url);
                $('#company_url').attr('href', xhr.url);
                //图片
                var imgs = xhr.environments.split(';');
                var imgs_len = imgs.length
                var imgs_html = '';
                if(imgs_len > 0){
                    imgs_html +='<ul>';
                    for(var i=0; i<imgs_len; i++){
                        imgs_html +='<li><img lay-src="'+imgs[i]+'"></li>';
                    }
                    imgs_html +='</ul>';
                }
                $('#environments').html(imgs_html);
            })
        })

	</script>
</body>
</html>